package com.liancheng.smarthome.bean.module;

import android.databinding.ObservableBoolean;
import android.databinding.ObservableField;
import android.databinding.ObservableInt;

import com.liancheng.smarthome.utils.appcommon.AppCommonUtils;
import com.liancheng.smarthome.utils.common.DateUtil;
import com.liancheng.smarthome.utils.constant.WorkerConstant;

import java.util.ArrayList;
import java.util.List;

/**
 * 报警页面的数据
 */
public class AlarmListItemBean  {

    public ObservableField<String > equipName = new ObservableField<>();
    public ObservableField<String > alarmContent = new ObservableField<>();
    public ObservableField<String > alarmTime = new ObservableField<>();

    public ObservableBoolean waitRead = new ObservableBoolean();

    public String alarmId ;

    public AlarmListItemBean(String alarmId,String equipNameI,String alarmContentI,String alarmTimeI,boolean waitReadI){
        this.equipName.set(equipNameI);
        this.alarmContent.set(alarmContentI);
        this.alarmTime.set(alarmTimeI);
        this.waitRead.set(waitReadI);

        this.alarmId = alarmId;
    }

    public static List<AlarmListItemBean> mergeFromData(List<AlarmListVMBean.ListBean> beans){
        if(AppCommonUtils.arrayIsEmtry(beans)) return null;
        List<AlarmListItemBean> alarmListItemBeans = new ArrayList<>();
        for (int i = 0; i < beans.size(); i++) {
            AlarmListVMBean.ListBean listBean = beans.get(i);
            alarmListItemBeans.add(new AlarmListItemBean(listBean.getAlarmId(),listBean.getDeviceName(),
                    listBean.getAlarmMsg(),
                    DateUtil.getStringForMillis(listBean.getAlarmTime(),DateUtil.DATE_YMDHMS1),
                    WorkerConstant.getReadTypeByTag(listBean.getStatus())));
        }
        return alarmListItemBeans;
    }

    public static List<AlarmListItemBean> buildData(){
        List<AlarmListItemBean> listItemBeans = new ArrayList<>();

        for (int i = 0; i < 20; i++) {
            listItemBeans.add(
                    new AlarmListItemBean("","山东省天桥区一体化预制泵设备","电压过高"
                    ,"2020/1/2 14:25:21",(i%2==1))
            );
        }
        return listItemBeans;
    }

}
